<!--#include file="functions.asp" -->
<%
'set cn=Server.CreateObject("ADODB.Connection")
'cn.Open "MP2ENTTEST2", "MP2", "MP2"
dim sql
dim txComments, rsvendor

'update exireg
  	sql = "UPDATE EXIREG SET "
	if (request("Route") ="UC") then
	sql = sql & " USERCOORD = '" & request("reqEndUser") & "',"
	else
	sql = sql & " VERIFIEDBY = '" & request("reqEndUser") & "',"
	end if
	sql = sql & " LOCATION = '" & request("reqEndUser") & "',"
	'sql = sql & " AUTHORISEDBY = '" & request("reqAuthorised") & "',"
	sql = sql & " USERDEPT = '" & request("Dept") & "',"
	sql = sql & " INVSTATUS='ROUTED',"
	sql = sql & " REFERENCEDOC='" & dblq(request("reqSupDoc")) & "',"
	if (request("Comments")<>"") then
    txComments = dblq(request("Comments1")) & Chr(13)
	txComments = txComments & ">" & UCase(UsrFullname) & "(" & now &"):  " 
	txComments = txComments & dblq(request("Comments"))
	sql = sql & " COMMENTS= '" & txComments & "',"
    end if
	sql = sql & " UPDATEUSER='" & usrName & "',"
	sql = sql & " UPDATESTAMP=GETDATE()" 
	sql = sql & " WHERE SEQNUM=" & request("seqnum2")

	cn.execute(sql)

'update exihist
	sql = "INSERT INTO EXIHIST (SEQNUM,TRANSTYPE,LOCATION,DEPARTMENT,DATE,UPDATEUSER,UPDATESTAMP)"
  	sql = sql & " VALUES ("
  	sql = sql & request("seqnum2") & ",'"
  	sql = sql & "IRT','"
 	sql = sql & request("reqEndUser") & "','"
  	sql = sql & request("Dept") & "','"
  	sql = sql & request("RouteDate") & "','"
  	sql = sql & usrName & "',"
  	sql = sql & "GETDATE() )"
    cn.execute(sql)

'create email notification
    sRecipients = GetLoginName(request("reqEndUser"))
    sDomainName = "@Premier-oil.com"
	EmailSubject = "Electronic Invoice Approval "  
	EmailBody = "<HTML><HEAD><TITLE></TITLE></HEAD><BODY>"
	EmailBody = EmailBody & "<FONT face=Arial size=2>Dear Sir/Madame </font><BR><BR>"
	EmailBody = EmailBody & "<FONT face=Arial size=2>Please find Invoice for your review: </font><BR><BR>"
	EmailBody = EmailBody & "<FONT face=Arial size=2>Vendor Name: " & request("Vendorname") & "</font><BR>"
	EmailBody = EmailBody & "<FONT face=Arial size=2>Invoice No: " & request("InvoiceNo") & "</font><BR>"
	EmailBody = EmailBody & "<FONT face=Arial size=2><b><a href='" & theURL & "/My_InvApproval.asp?seqnum=" &  request("seqnum2")  & "'>Click here for Invoice detail</a></b></font><BR><BR>"
	EmailBody = EmailBody & "<FONT face=Arial size=2>Thank you for your kind cooperation </font><BR><BR>"
	EmailBody = EmailBody & "<FONT face=Arial size=2><b>Finance Department </b></font>"
	EmailBody = EmailBody & "</BODY></HTML>"
	
	Dim MyBody
	MyBody = ReformatText(EmailBody)
	SendCDOEmail sRecipients, "", "", "Finance_Department", EmailSubject, MyBody

'response.redirect "Inv_Detail.asp?seqnum="& request("seqnum2")& "&Order=" & request("order")& "&Sort=" & request("sort")
response.redirect "Inv_Detail.asp?seqnum="& request("seqnum2") &"&InvStatus="& request("InvStatus")&"&dsort="& request("dsort")&"&dorder="&request("dorder") &"&Location="&request("Location")&"&UserCoord="&request("UserCoord")&"&RefOrder="&request("RefOrder")&"&VendorID="&request("VendorID")&"&CurSymbol="& request("CurSymbol")


%>
